import request from '@/utils/request'

// 权限
export function roleFetchList(query) {
  return request({
    url: 'role/list',
    method: 'get',
    params: query
  })
}

export function createRole(data) {
  return request({
    url: '/role/add',
    method: 'post',
    data
  })
}

export function getTotal(data) {
  return request({
    url: '/chauffeur/query/online',
    method: 'get',
    data
  })
}

export function searchList(data) {
  console.log(data)
  return request({
    url: '/chauffeur/search/' + data.idCardNo,
    method: 'get',
    params: data
  })
}

export function searchUserList(data) {
  return request({
    url: '/admin/search',
    method: 'get',
    params: data
  })
}

export function stopCar(id, type) {
  console.log(id)
  return request({
    url: '/admin/delete/' + id + '/' + type,
    method: 'DELETE',
    params: { id }
  })
}
export function backCar(id) {
  console.log(id)
  return request({
    url: '/chauffeur/back/' + id,
    method: 'put',
    params: { id }
  })
}

// 用户
export function userFetchList(query) {
  return request({
    url: '/admin/list',
    method: 'get',
    params: query
  })
}

export function createUser(data) {
  return request({
    url: '/admin/add',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/admin/edit',
    method: 'put',
    data
  })
}
export function detailUser(data) {
  return request({
    url: '/admin/get/' + data,
    method: 'get',
    data
  })
}

// banner

export function bannerList(data) {
  return request({
    url: '/management/banner/list',
    method: 'get',
    data
  })
}
export function createBanner(data) {
  return request({
    url: '/management/banner/save',
    method: 'post',
    data: data
  })
}
export function deleteBanner(id) {
  return request({
    url: '/management/banner/delete/' + id,
    method: 'put'
  })
}
export function changeBannerState(id, state) {
  return request({
    url: '/management/banner/edit/' + id + '/' + state,
    method: 'put'
  })
}
export function updateBanner(data) {
  return request({
    url: '/management/banner/update',
    method: 'put',
    data: data
  })
}
